"use strict";
cc._RF.push(module, 'b88d7V9PGNMS5tkFS9vFbcB', 'AssetsManager');
// scripts/AssetsManager.js

"use strict";

var e = require;
var t = module;
var o = exports;

var _ii,
    nn = void 0 && (void 0).__extends || (_ii = function ii(t, e) {
  return (_ii = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _ii(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    rr = void 0 && (void 0).__awaiter || function (t, e, o, i) {
  return new (o || (o = Promise))(function (n, a) {
    function r(t) {
      try {
        l(i.next(t));
      } catch (e) {
        a(e);
      }
    }

    function s(t) {
      try {
        l(i["throw"](t));
      } catch (e) {
        a(e);
      }
    }

    function l(t) {
      var e;
      t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
        t(e);
      })).then(r, s);
    }

    l((i = i.apply(t, e || [])).next());
  });
},
    ss = void 0 && (void 0).__generator || function (t, e) {
  var o,
      i,
      n,
      a,
      r = {
    label: 0,
    sent: function sent() {
      if (1 & n[0]) throw n[1];
      return n[1];
    },
    trys: [],
    ops: []
  };
  return a = {
    next: s(0),
    "throw": s(1),
    "return": s(2)
  }, "function" == typeof Symbol && (a[Symbol.iterator] = function () {
    return this;
  }), a;

  function s(t) {
    return function (e) {
      return l([t, e]);
    };
  }

  function l(a) {
    if (o) throw new TypeError("Generator is already executing.");

    for (; r;) {
      try {
        if (o = 1, i && (n = 2 & a[0] ? i["return"] : a[0] ? i["throw"] || ((n = i["return"]) && n.call(i), 0) : i.next) && !(n = n.call(i, a[1])).done) return n;

        switch (i = 0, n && (a = [2 & a[0], n.value]), a[0]) {
          case 0:
          case 1:
            n = a;
            break;

          case 4:
            return r.label++, {
              value: a[1],
              done: !1
            };

          case 5:
            r.label++, i = a[1], a = [0];
            continue;

          case 7:
            a = r.ops.pop(), r.trys.pop();
            continue;

          default:
            if (!(n = (n = r.trys).length > 0 && n[n.length - 1]) && (6 === a[0] || 2 === a[0])) {
              r = 0;
              continue;
            }

            if (3 === a[0] && (!n || a[1] > n[0] && a[1] < n[3])) {
              r.label = a[1];
              break;
            }

            if (6 === a[0] && r.label < n[1]) {
              r.label = n[1], n = a;
              break;
            }

            if (n && r.label < n[2]) {
              r.label = n[2], r.ops.push(a);
              break;
            }

            n[2] && r.ops.pop(), r.trys.pop();
            continue;
        }

        a = e.call(t, r);
      } catch (s) {
        a = [6, s], i = 0;
      } finally {
        o = n = 0;
      }
    }

    if (5 & a[0]) throw a[1];
    return {
      value: a[0] ? a[1] : void 0,
      done: !0
    };
  }
};

var oo = void 0 && (void 0).__decorate || function (e, t, a, n) {
  var i,
      o = arguments.length,
      s = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, a) : n;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);else for (var r = e.length - 1; r >= 0; r--) {
    (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
  }
  return o > 3 && s && Object.defineProperty(t, a, s), s;
};

Object.defineProperty(o, "__esModule", {
  value: !0
}), o.AssetsType = void 0;
var a,
    n = e("Loader"),
    i = e("AudioManager"),
    r = cc._decorator,
    s = r.ccclass;
r.property, function (e) {
  e[e.Prefabs = 1] = "Prefabs", e[e.Sprite = 2] = "Sprite", e[e.Atlas = 3] = "Atlas", e[e.Audio = 4] = "Audio", e[e.Bundle = 5] = "Bundle";
}(a = o.AssetsType || (o.AssetsType = {}));

var l = function () {
  function e() {
    this.Prefabs = {}, this.Sprite = {}, this.Atlas = {}, this.Audio = {}, this.FightProfabs = {}, this.FightAddName = [];
  }

  var t;
  return t = e, e.getInstance = function () {
    return this.instance || (this.instance = new t()), this.instance;
  }, e.prototype.loadFolder = function (e, t) {
    return rr(this, void 0, void 0, function () {
      var o;
      return ss(this, function () {
        console.log(o, t);

        switch (o = null, t) {
          case a.Prefabs:
            o = this.loadPrefabs(e);
            break;

          case a.Sprite:
            o = this.loadSprite(e);
            break;

          case a.Atlas:
            o = this.loadAtlas(e);
            break;

          case a.Audio:
            o = this.loadAudio(e);
            break;

          case a.Bundle:
            o = this.loadBundlePrefabs(e);
        }

        return [2, o];
      });
    });
  }, e.prototype.loadPrefabs = function (e) {
    var t = this;
    return new Promise(function (o) {
      cc.assetManager.getBundle(e)._config.paths.forEach(function (o, a) {
        n["default"].loadBundleRes(e, a, function (e) {
          t.Prefabs[a] = e;
        }, cc.Prefab);
      }), o();
    });
  }, e.prototype.loadBundlePrefabs = function (e) {
    console.log("loadBundlePrefabs");
    var t = this;
    return new Promise(function (o) {
      cc.assetManager.getBundle(e)._config.paths.forEach(function (o, a) {
        n["default"].loadBundleRes(e, a, function (e) {
          t.Prefabs[a] = e;
        }, cc.Prefab);
        console.log("loadBundlePrefabs2");
      }), o();
    });
  }, e.prototype.loadSprite = function (e) {
    var t = this;
    return new Promise(function (o) {
      cc.assetManager.getBundle(e)._config.paths.forEach(function (o, a) {
        n["default"].loadBundleRes(e, a, function (e) {
          var o = "" + a;
          t.Sprite[o] = e;
        }, cc.SpriteFrame);
      }), o();
    });
  }, e.prototype.loadAtlas = function () {
    var e = this;
    return new Promise(function (t) {
      cc.assetManager.getBundle("Atlas")._config.paths.forEach(function (t, o) {
        n["default"].loadBundleRes("Atlas", o, function (t) {
          var a = "" + o;
          e.Atlas[a + ".plist"] = t;
        }, cc.SpriteAtlas);
      }), t();
    });
  }, e.prototype.loadAudio = function (e) {
    var t = this;
    return new Promise(function (o, a) {
      cc.resources.loadDir(e, cc.AudioClip, null, function (e, n) {
        if (e) a(e);else {
          for (var r = 0; r < n.length; r++) {
            n[r] && (t.Audio[n[r].name] = n[r], i["default"].getInstance().addSound(n[r].name, n[r]));
          }

          o();
        }
      });
    });
  }, e.prototype.getPrefabNode = function (e) {
    return this.Prefabs[e];
  }, e.prototype.loadFightPrefabs = function (e) {
    var t = this;
    return new Promise(function (o) {
      cc.assetManager.getBundle(e)._config.paths.forEach(function (o, a) {
        n["default"].loadBundleRes(e, a, function (e) {
          t.FightProfabs[a] = e;
        }, cc.Prefab);
      }), o();
    });
  }, e.prototype.loadFightRolePrefabs = function (e) {
    var t = this;
    return this.FightAddName = e, new Promise(function (o, a) {
      for (var n = 0; n < e.length; n++) {
        var i = e[n];
        cc.resources.load(i, cc.Prefab, null, function (e, o) {
          e ? a(e) : t.FightProfabs[o.name] = o;
        });
      }

      o();
    });
  }, e.prototype.loadFightAudio = function (e) {
    var t = this;
    return new Promise(function (o, a) {
      cc.resources.loadDir(e, cc.AudioClip, null, function (e, n) {
        if (e) a(e);else {
          for (var r = 0; r < n.length; r++) {
            n[r] && (t.Audio[n[r].name] = n[r], i["default"].getInstance().addFightSound(n[r].name, n[r]));
          }

          o();
        }
      });
    });
  }, e.prototype.getPlayerLevelExp = function (e) {
    return this.Atlas["level_atlas.plist"].getSpriteFrame("level_" + e);
  }, e.prototype.getHeroHeadFrame = function (e) {
    return this.Atlas["hero_head.plist"].getSpriteFrame(e);
  }, e.prototype.getGameHoreHeadFrame = function (e) {
    return this.Atlas["game_hero_head.plist"].getSpriteFrame(e);
  }, e.prototype.getGradeTypeFrame = function (e) {
    return this.Atlas["level_atlas.plist"].getSpriteFrame(e);
  }, e.prototype.getDowerImagerFrame = function (e) {
    return this.Atlas["dower_image.plist"].getSpriteFrame(e);
  }, e.prototype.getHeroCardFrame = function (e) {
    return this.Atlas["hero_card.plist"].getSpriteFrame(e);
  }, e.prototype.getHeroSkilIcon = function (e) {
    return this.Atlas["hero_skill_icon.plist"].getSpriteFrame(e);
  }, e.prototype.getPlayerSkillFrame = function (e) {
    return this.Atlas["player_skill.plist"].getSpriteFrame(e);
  }, e.prototype.getEquipIconFrame = function (e) {
    return this.Atlas["equip_icon.plist"].getSpriteFrame(e);
  }, e.prototype.getModeInfoFrame = function (e) {
    return this.Atlas["mode_info_atlas.plist"].getSpriteFrame(e);
  }, e.prototype.getFightPrefab = function (e) {
    return this.FightProfabs[e];
  }, e.prototype.getTexture2DSprite = function (e) {
    return this.Sprite[e];
  }, t = oo([s], e);
}();

o["default"] = l;

cc._RF.pop();